package com.nebula.api.modules.message.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.nebula.api.utils.Constants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode()
@Accessors(chain = true)
@TableName("SYSTEM_MESSAGE")
public class SystemMessage {
    /**
     * 是否置顶
     */
    public static final Integer TOP_TRUE = 1;
    public static final Integer TOP_FALSE = 0;

    /**
     * 消息类型
     */
    public static final Integer TYPE_ALL = 0;
    public static final Integer TYPE_SYSTEM = 1;
    public static final Integer TYPE_USER = 2;

    /**
     * 是否已读
     */
    public static final Integer IS_READER_TRUE = 0;
    public static final Integer IS_READER_FALSE = 1;

    @TableId(value = "id", type = IdType.AUTO)
    private int id;
    /**
     * 消息类型 0:全部消息 1:系统消息 2:个人消息
     */
    @TableField("TYPE")
    private Integer type;
    /**
     * 消息内容
     */
    @TableField("MSG_DATE")
    private String msgDate;
    /**
     * 创建时间
     */
    @TableField("CREATE_TIME")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = Constants.DEFAULT_TIMEZONE)
    private LocalDateTime createTime;
    /**
     * 是否置顶
     */
    @TableField("TOP")
    private Integer top;
    /**
     * 发布人
     */
    @TableField("SOURCE_NAME")
    private String sourceName;
    /**
     * 收件人
     */
    @TableField("SEND_NAME")
    private String sendName;
    /**
     * 消息标题
     */
    @TableField("title")
    private String title;

    @TableField("IS_READER")
    private Integer isReader;

    public SystemMessage() {

    }

    public SystemMessage(int id, Integer type, String msgDate, LocalDateTime createTime, Integer top, String sourceName, String sendName, String title, Integer isReader) {
        this.id = id;
        this.type = type;
        this.msgDate = msgDate;
        this.createTime = createTime;
        this.top = top;
        this.sourceName = sourceName;
        this.sendName = sendName;
        this.title = title;
        this.isReader = isReader;
    }
}
